/*
 * Filename:    WarningController.java
 * Copyright:   2014 中国平安保险（集团）股份有限公司 版权所有
 * Company:     平安科技养老险及健康险系统开发部
 * Create at:   2014年10月24日
 */
package com.paic.mhis.hcpms.warning.web.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.paic.mhis.core.auth.biz.service.UserDetails;
import com.paic.mhis.hcpms.common.base.util.PropertyCopyUtil;
import com.paic.mhis.hcpms.warning.biz.service.SelfFeedbackService;
import com.paic.mhis.hcpms.warning.dto.PaginationQueryDTO;
import com.paic.mhis.hcpms.warning.util.WarnConstants;
import com.paic.mhis.hcpms.warning.web.vo.WarningGtasksVO;
import com.paic.pafa.app.biz.service.BusinessServiceException;
import com.paic.pafa.appclient.annotation.BizServicesProxy;
import com.paic.pafa.web.BaseRest;

@Controller
public class SelfFeedbackController extends BaseRest {
	@BizServicesProxy
	private SelfFeedbackService selfFeedbackService;

	/**
	 * 获取节点数据
	 * 
	 * @param
	 * @return
	 */
	@RequestMapping(value = "/warnfeedback/getfeedbackstatus.do")
	public Map<String, Object> getFeedbackStatus(HttpServletRequest request) {
		Map<String, Object> result = new HashMap<String, Object>();
		try {
			result = selfFeedbackService.getfeedbackstatus();
		} catch (BusinessServiceException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
	}

	/**
	 * 获取反馈处理方式数据
	 * 
	 * @param
	 * @return
	 */
	@RequestMapping(value = "/warnfeedback/getfeedbackprocess.do")
	public Map<String, Object> getFeedbackProcess(HttpServletRequest request) {
		Map<String, Object> result = new HashMap<String, Object>();
		try {
			result = selfFeedbackService.getfeedbackprocess();
		} catch (BusinessServiceException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
	}

	/**
	 * 查询反馈列表
	 * 
	 * @param
	 * @return
	 */
	@RequestMapping(value = "/warnfeedback/findWarningFeedbackList.do")
	@ResponseBody
	public Map<String, Object> findWarningAddList(@ModelAttribute WarningGtasksVO taskVo, HttpServletRequest request) {
		Map<String, Object> result = new HashMap<String, Object>();
		try {
			UserDetails user = (UserDetails) request.getSession().getAttribute("user");
			PaginationQueryDTO paginationCon = new PaginationQueryDTO();
			Map<String, Object> condition = new HashMap<String, Object>();
			PropertyCopyUtil.propertyCopyForMap(condition, taskVo);
			List<String> statusList = new ArrayList<String>();
			if (condition.get("isFeedback") != null && "01".equals(condition.get("isFeedback"))) {
				condition.put("isFeedbackAsc", condition.get("isFeedback"));
			} else if (condition.get("isFeedback") != null && "02".equals(condition.get("isFeedback"))) {
				condition.put("isFeedbackDesc", condition.get("isFeedback"));
			}
			condition.put("statusList", statusList);
			condition.put("assigner", user.getUsername());
			condition.put("role", WarnConstants.WARN_HOSPITAL);
			paginationCon.setParam(condition);
			paginationCon.setLimit(taskVo.getLimit());
			paginationCon.setStart(taskVo.getStart());
			result = selfFeedbackService.getGTasks(paginationCon);
			result.put(WarnConstants.STATE_KEY, WarnConstants.SUCCESS_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SELECT_SUCCESS);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return result;
	}

}
